package com.xuecheng.content.api.controller;

import com.xuecheng.content.model.dto.BindTeachplanMediaDto;
import com.xuecheng.content.model.dto.MoveTeachPlanDto;
import com.xuecheng.content.model.dto.SaveTeachplanDto;
import com.xuecheng.content.model.dto.TeachplanDto;
import com.xuecheng.content.service.TeachplanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author Mr.M
 * @version 1.0
 * @description 课程计划信息接口
 * @date 2024/12/17 11:06
 */
@Api(value = "课程计划信息接口", tags = "课程计划信息接口")
@RestController
public class TeachplanController {
    @Autowired
    TeachplanService teachplanService;

    @ApiOperation("查询课程技术树形结构")
    @ApiImplicitParam(value = "courseId", name = "课程id", required = true, dataType = "Long", paramType = "path")
    @GetMapping("/teachplan/{courseId}/tree-nodes")
    public List<TeachplanDto> getTreeNodes(@PathVariable Long courseId) {
        return teachplanService.findTeachplanTree(courseId);
    }

    @ApiOperation("课程计划创建或修改")
    @PostMapping("/teachplan")
    public void saveTeachplan(@RequestBody SaveTeachplanDto teachplan) {
        teachplanService.saveTeachplan(teachplan);
    }

    @ApiOperation("删除课程计划")
    @ApiImplicitParam(value = "id", name = "课程计划id", required = true, dataType = "Long", paramType = "path")
    @DeleteMapping("/teachplan/{id}")
    public void deleteTeachPlan(@PathVariable Long id) {
        teachplanService.deleteTeachplan(id);
    }


    @ApiOperation("课程计划排序")
    @ApiImplicitParam(value = "id", name = "课程计划id", required = true, dataType = "Long", paramType = "path")
    @PostMapping("/teachplan/{moveType}/{id}")
    public void movedown(@PathVariable String moveType, @PathVariable Long id, @RequestBody MoveTeachPlanDto moveTeachPlanDto) {
        teachplanService.moveTeachplan(moveType, id, moveTeachPlanDto);
    }


    @ApiOperation("课程计划绑定媒资关系")
    @PostMapping("/teachplan/association/media")
    public void associationMedia(@RequestBody BindTeachplanMediaDto bindTeachplanMediaDto) {
        teachplanService.associationMedia(bindTeachplanMediaDto);
    }


}
